import OSS from "ali-oss";
import env from '@/ossutil/config.js'
const client = new OSS({
  region: env.region,
  accessKeyId: env.OSSAccessKeyId,
  accessKeySecret: env.AccessKeySecret,
  bucket: env.bucket
});
// 过期时间10分钟,图片处理式样"image/resize,w_300"。
let signFun = function (url) {
  let url1 = url
  if (url && url.indexOf('aos/') != -1) {
    url1 = client.signatureUrl(url, { expires: 600 });
    // url1 = url1 && url1.replace('oss-cn-hangzhou-zwynet-d01-a.aliyuncs.com','oss-cn-hangzhou-zwynet-d01-a.internet.cloud.zj.gov.cn')
    // // 图片不是公共读时需去掉
    // url1 = url1 && url1.split('?')[0]
  }


  return url1;
}
export { signFun }